package com.imddy.spbatch001.exceptionhandler;


import com.imddy.spbatch001.utils.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalDefaultExceptionHandler {
    private static final Logger log = LoggerFactory.getLogger(GlobalDefaultExceptionHandler.class);


    @ExceptionHandler(Exception.class)
    @ResponseBody
    public AjaxResult exception(Exception e) {
        e.printStackTrace();
        log.error("发生了Exception异常: " + e.getMessage());
        return AjaxResult.error("发生了未知异常");
    }

}
